package net.lab1024.sa.admin.module.business.erp.controller;

import net.lab1024.sa.admin.module.business.erp.domain.form.add.ApprovordaAddForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.query.ApprovordaQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.ApprovordaUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.ApprovordaVO;
import net.lab1024.sa.admin.module.business.erp.service.ApprovordaService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 审批细表 Controller
 *
 * @Author AKITA
 * @Date 2025-04-23 14:10:18
 * @Copyright AKITA
 */

@RestController
@Tag(name = "审批细表")
public class ApprovordaController {

    @Resource
    private ApprovordaService approvordaService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/approvorda/queryPage")
    @SaCheckPermission("approvorda:query")
    public ResponseDTO<PageResult<ApprovordaVO>> queryPage(@RequestBody @Valid ApprovordaQueryForm queryForm) {
        return ResponseDTO.ok(approvordaService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/approvorda/add")
    @SaCheckPermission("approvorda:add")
    public ResponseDTO<String> add(@RequestBody @Valid ApprovordaAddForm addForm) {
        return approvordaService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/approvorda/update")
    @SaCheckPermission("approvorda:update")
    public ResponseDTO<String> update(@RequestBody @Valid ApprovordaUpdateForm updateForm) {
        return approvordaService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/approvorda/batchDelete")
    @SaCheckPermission("approvorda:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return approvordaService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/approvorda/delete/{docEntry}")
    @SaCheckPermission("approvorda:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return approvordaService.delete(docEntry);
    }
}
